#ifndef _BITSTREAM_H_
#define _BITSTREAM_H_

#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )

//convert array of char to bitstream (8 bits per 8-bit word)
unsigned char *to_bitstream_compact(
				    unsigned char *,
				    unsigned int,
				    unsigned int *
				    );

//convert array of char to bitstream (1 bit per 8-bit word)
unsigned char *to_bitstream_flat(
				 unsigned char *,
				 unsigned int,
				 unsigned int *
				 );

//write a bitstream to file
void bistream_to_file(
		      const char *,
		      unsigned char *,
		      unsigned char *,
		      unsigned char *,
		      unsigned int,
		      unsigned int,
		      unsigned int
		      );

//write a (single) bitstream to file
void bistream_to_file_single(
		      const char *,
		      unsigned char *,
		      unsigned int
		      );

//read a 32-bit from a bitstream
unsigned int to_int32(
		      unsigned char *,
		      unsigned int
		      );

#endif
